#include "config.hpp"
#include <boost/log/trivial.hpp>

namespace net_channel {
namespace server {

Config::Config(const std::string& config_file) {
    load_config(config_file);
}

void Config::load_config(const std::string& config_file) {
    try {
        boost::property_tree::ptree pt;
        boost::property_tree::read_yaml(config_file, pt);

        tcp_listener_.port = pt.get<uint16_t>("tcp_listener.port");
        
        BOOST_LOG_TRIVIAL(info) << "Server config loaded successfully";
        BOOST_LOG_TRIVIAL(info) << "TCP listener port: " << tcp_listener_.port;
    } catch (const std::exception& e) {
        BOOST_LOG_TRIVIAL(error) << "Failed to load server config: " << e.what();
        throw;
    }
}

} // namespace server
} // namespace net_channel